package com.bawei.base.mvvm

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider

abstract class BaseActivity<VDB: ViewDataBinding,VM:ViewModel>: AppCompatActivity() {

    lateinit var binding:VDB
    lateinit var viewModel:VM

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //
        binding = DataBindingUtil.setContentView(this,getLoutyId())
        //
        viewModel = ViewModelProvider(this)[getViewModel()]
        //
        initView()
        initDate()
    }

    //
    abstract fun getLoutyId():Int
    //
    abstract fun getViewModel():Class<VM>
    //
    abstract fun initView()
    abstract fun initDate()
}